home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / GNU / emacs.inst / emacs19.idb / usr / gnu / info / elisp-26.z / elisp-26
Encoding:
GNU Info File  |  1994-08-02  |  48.6 KB  |  1,146 lines

  1. This is Info file elisp, produced by Makeinfo-1.55 from the input file
  2. elisp.texi.
  3.  
  4.    This version is newer than the second printed edition of the GNU
  5. Emacs Lisp Reference Manual.  It corresponds to Emacs Version 19.19.
  6.  
  7.    Published by the Free Software Foundation 675 Massachusetts Avenue
  8. Cambridge, MA 02139 USA
  9.  
  10.    Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  11.  
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.  
  16.    Permission is granted to copy and distribute modified versions of
  17. this manual under the conditions for verbatim copying, provided that
  18. the entire resulting derived work is distributed under the terms of a
  19. permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions, except that this permission notice may be stated in a
  24. translation approved by the Foundation.
  25.  
  26.    Permission is granted to copy and distribute modified versions of
  27. this manual under the conditions for verbatim copying, provided also
  28. that the section entitled "GNU Emacs General Public License" is included
  29. exactly as in the original, and provided that the entire resulting
  30. derived work is distributed under the terms of a permission notice
  31. identical to this one.
  32.  
  33.    Permission is granted to copy and distribute translations of this
  34. manual into another language, under the above conditions for modified
  35. versions, except that the section entitled "GNU Emacs General Public
  36. License" may be included in a translation approved by the Free Software
  37. Foundation instead of in the original English.
  38.  
  39. 
  40. File: elisp,  Node: Abbrev Tables,  Next: Defining Abbrevs,  Prev: Abbrev Mode,  Up: Abbrevs
  41.  
  42. Abbrev Tables
  43. =============
  44.  
  45.    This section describes how to create and manipulate abbrev tables.
  46.  
  47.  - Function: make-abbrev-table
  48.      This function creates and returns a new, empty abbrev table--an
  49.      obarray containing no symbols.  It is a vector filled with `nil's.
  50.  
  51.  - Function: clear-abbrev-table TABLE
  52.      This function undefines all the abbrevs in abbrev table TABLE,
  53.      leaving it empty.  The function returns `nil'.
  54.  
  55.  - Function: define-abbrev-table TABNAME DEFINITIONS
  56.      This function defines TABNAME (a symbol) as an abbrev table name,
  57.      i.e., as a variable whose value is an abbrev table.  It defines
  58.      abbrevs in the table according to DEFINITIONS, a list of elements
  59.      of the form `(ABBREVNAME EXPANSION HOOK USECOUNT)'.  The value is
  60.      always `nil'.
  61.  
  62.  - Variable: abbrev-table-name-list
  63.      This is a list of symbols whose values are abbrev tables.
  64.      `define-abbrev-table' adds the new abbrev table name to this list.
  65.  
  66.  - Function: insert-abbrev-table-description NAME &optional HUMAN
  67.      This function inserts before point a description of the abbrev
  68.      table named NAME.  The argument NAME is a symbol whose value is an
  69.      abbrev table.  The value is always `nil'.
  70.  
  71.      If HUMAN is non-`nil', a human-oriented description is inserted.
  72.      Otherwise the description is a Lisp expression--a call to
  73.      `define-abbrev-table' which would define NAME exactly as it is
  74.      currently defined.
  75.  
  76. 
  77. File: elisp,  Node: Defining Abbrevs,  Next: Abbrev Files,  Prev: Abbrev Tables,  Up: Abbrevs
  78.  
  79. Defining Abbrevs
  80. ================
  81.  
  82.    These functions define an abbrev in a specified abbrev table.
  83. `define-abbrev' is the low-level basic function, while `add-abbrev' is
  84. used by commands that ask for information from the user.
  85.  
  86.  - Function: add-abbrev TABLE TYPE ARG
  87.      This function adds an abbreviation to abbrev table TABLE.  The
  88.      argument TYPE is a string describing in English the kind of abbrev
  89.      this will be (typically, `"global"' or `"mode-specific"'); this is
  90.      used in prompting the user.  The argument ARG is the number of
  91.      words in the expansion.
  92.  
  93.      The return value is the symbol which internally represents the new
  94.      abbrev, or `nil' if the user declines to redefine an existing
  95.      abbrev.
  96.  
  97.  - Function: define-abbrev TABLE NAME EXPANSION HOOK
  98.      This function defines an abbrev in TABLE named NAME, to expand to
  99.      EXPANSION, and call HOOK.  The return value is an uninterned
  100.      symbol which represents the abbrev inside Emacs; its name is NAME.
  101.  
  102.      The argument NAME should be a string.  The argument EXPANSION
  103.      should be a string, or `nil', to undefine the abbrev.
  104.  
  105.      The argument HOOK is a function or `nil'.  If HOOK is non-`nil',
  106.      then it is called with no arguments after the abbrev is replaced
  107.      with EXPANSION; point is located at the end of EXPANSION.
  108.  
  109.      The use count of the abbrev is initialized to zero.
  110.  
  111.  - User Option: only-global-abbrevs
  112.      If this variable is non-`nil', it means that the user plans to use
  113.      global abbrevs only.  This tells the commands that define
  114.      mode-specific abbrevs to define global ones instead.  This
  115.      variable does not alter the functioning of the functions in this
  116.      section; it is examined by their callers.
  117.  
  118. 
  119. File: elisp,  Node: Abbrev Files,  Next: Abbrev Expansion,  Prev: Defining Abbrevs,  Up: Abbrevs
  120.  
  121. Saving Abbrevs in Files
  122. =======================
  123.  
  124.    A file of saved abbrev definitions is actually a file of Lisp code.
  125. The abbrevs are saved in the form of a Lisp program to define the same
  126. abbrev tables with the same contents.  Therefore, you can load the file
  127. with `load' (*note How Programs Do Loading::.).  However, the function
  128. `quietly-read-abbrev-file' is provided as a more convenient interface.
  129.  
  130.    User-level facilities such as `save-some-buffers' can save abbrevs
  131. in a file automatically, under the control of variables described here.
  132.  
  133.  - User Option: abbrev-file-name
  134.      This is the default file name for reading and saving abbrevs.
  135.  
  136.  - Function: quietly-read-abbrev-file FILENAME
  137.      This function reads abbrev definitions from a file named FILENAME,
  138.      previously written with `write-abbrev-file'.  If FILENAME is
  139.      `nil', the file specified in `abbrev-file-name' is used.
  140.      `save-abbrevs' is set to `t' so that changes will be saved.
  141.  
  142.      This function does not display any messages.  It returns `nil'.
  143.  
  144.  - User Option: save-abbrevs
  145.      A non-`nil' value for `save-abbrev' means that Emacs should save
  146.      abbrevs when files are saved.  `abbrev-file-name' specifies the
  147.      file to save the abbrevs in.
  148.  
  149.  - Variable: abbrevs-changed
  150.      This variable is set non-`nil' by defining or altering any
  151.      abbrevs.  This serves as a flag for various Emacs commands to
  152.      offer to save your abbrevs.
  153.  
  154.  - Command: write-abbrev-file FILENAME
  155.      Save all abbrev definitions, in all abbrev tables, in the file
  156.      FILENAME, in the form of a Lisp program which when loaded will
  157.      define the same abbrevs.  This function returns `nil'.
  158.  
  159. 
  160. File: elisp,  Node: Abbrev Expansion,  Next: Standard Abbrev Tables,  Prev: Abbrev Files,  Up: Abbrevs
  161.  
  162. Looking Up and Expanding Abbreviations
  163. ======================================
  164.  
  165.    Abbrevs are usually expanded by commands for interactive use,
  166. including `self-insert-command'.  This section describes the
  167. subroutines used in writing such functions, as well as the variables
  168. they use for communication.
  169.  
  170.  - Function: abbrev-symbol ABBREV &optional TABLE
  171.      This function returns the symbol representing the abbrev named
  172.      ABBREV.  The value returned is `nil' if that abbrev is not
  173.      defined.  The optional second argument TABLE is the abbrev table
  174.      to look it up in.  By default, this function tries first the
  175.      current buffer's local abbrev table, and second the global abbrev
  176.      table.
  177.  
  178.  - User Option: abbrev-all-caps
  179.      When this is set non-`nil', an abbrev entered entirely in upper
  180.      case is expanded using all upper case.  Otherwise, an abbrev
  181.      entered entirely in upper case is expanded by capitalizing each
  182.      word of the expansion.
  183.  
  184.  - Function: abbrev-expansion ABBREV &optional TABLE
  185.      This function returns the string that ABBREV would expand into (as
  186.      defined by the abbrev tables used for the current buffer).  The
  187.      optional argument TABLE specifies the abbrev table to use; if it is
  188.      specified, the abbrev is looked up in that table only.
  189.  
  190.  - Variable: abbrev-start-location
  191.      This is the buffer position for `expand-abbrev' to use as the start
  192.      of the next abbrev to be expanded.  (`nil' means use the word
  193.      before point instead.)  `abbrev-start-location' is set to `nil'
  194.      each time `expand-abbrev' is called.  This variable is also set by
  195.      `abbrev-prefix-mark'.
  196.  
  197.  - Variable: abbrev-start-location-buffer
  198.      The value of this variable is the buffer for which
  199.      `abbrev-start-location' has been set.  Trying to expand an abbrev
  200.      in any other buffer clears `abbrev-start-location'.  This variable
  201.      is set by `abbrev-prefix-mark'.
  202.  
  203.  - Variable: last-abbrev
  204.      This is the `abbrev-symbol' of the last abbrev expanded.  This
  205.      information is left by `expand-abbrev' for the sake of the
  206.      `unexpand-abbrev' command.
  207.  
  208.  - Variable: last-abbrev-location
  209.      This is the location of the last abbrev expanded.  This contains
  210.      information left by `expand-abbrev' for the sake of the
  211.      `unexpand-abbrev' command.
  212.  
  213.  - Variable: last-abbrev-text
  214.      This is the exact expansion  text of the last abbrev expanded, as
  215.      results from case conversion.  Its value is `nil' if the abbrev
  216.      has already been unexpanded.  This contains information left by
  217.      `expand-abbrev' for the sake of the `unexpand-abbrev' command.
  218.  
  219.  - Variable: pre-abbrev-expand-hook
  220.      This is a normal hook whose functions are executed, in sequence,
  221.      just before any expansion of an abbrev.  *Note Hooks::.  Since it
  222.      is a normal hook, the hook functions receive no arguments.
  223.      However, they can find the abbrev to be expanded by looking in the
  224.      buffer before point.
  225.  
  226.    The following sample code shows a simple use of
  227. `pre-abbrev-expand-hook'.  If the user terminates an abbrev with a
  228. punctuation character, the function issues a prompt.  Thus, this hook
  229. allows the user to decide whether the abbrev should be expanded, and to
  230. abort expansion if it is not desired.
  231.  
  232.      (add-hook 'pre-abbrev-expand-hook 'query-if-not-space)
  233.      
  234.      ;; This is the function invoked by `pre-abbrev-expand-hook'.
  235.      
  236.      ;; If the user terminated the abbrev with a space, the function does
  237.      ;; nothing (that is, it returns so that the abbrev can expand).  If the
  238.      ;; user entered some other character, this function asks whether
  239.      ;; expansion should continue.
  240.      
  241.      ;; If the user enters the prompt with `y', the function returns
  242.      ;; `nil' (because of the `not' function), but that is
  243.      ;; acceptable; the return value has no effect on expansion.
  244.      
  245.      (defun query-if-not-space ()
  246.        (if (/= ?\  (preceding-char))
  247.            (if (not (y-or-n-p "Do you want to expand this abbrev? "))
  248.                (error "Not expanding this abbrev"))))
  249.  
  250. 
  251. File: elisp,  Node: Standard Abbrev Tables,  Prev: Abbrev Expansion,  Up: Abbrevs
  252.  
  253. Standard Abbrev Tables
  254. ======================
  255.  
  256.    Here we list the variables that hold the abbrev tables for the
  257. preloaded major modes of Emacs.
  258.  
  259.  - Variable: global-abbrev-table
  260.      This is the abbrev table for mode-independent abbrevs.  The abbrevs
  261.      defined in it apply to all buffers.  Each buffer may also have a
  262.      local abbrev table, whose abbrev definitions take precedence over
  263.      those in the global table.
  264.  
  265.  - Variable: local-abbrev-table
  266.      The value of this buffer-local variable is the (mode-specific)
  267.      abbreviation table of the current buffer.
  268.  
  269.  - Variable: fundamental-mode-abbrev-table
  270.      This is the local abbrev table used in Fundamental mode.  It is the
  271.      local abbrev table in all buffers in Fundamental mode.
  272.  
  273.  - Variable: text-mode-abbrev-table
  274.      This is the local abbrev table used in Text mode.
  275.  
  276.  - Variable: c-mode-abbrev-table
  277.      This is the local abbrev table used in C mode.
  278.  
  279.  - Variable: lisp-mode-abbrev-table
  280.      This is the local abbrev table used in Lisp mode and Emacs Lisp
  281.      mode.
  282.  
  283. 
  284. File: elisp,  Node: Processes,  Next: System Interface,  Prev: Abbrevs,  Up: Top
  285.  
  286. Processes
  287. *********
  288.  
  289.    In the terminology of operating systems, a "process" is a space in
  290. which a program can execute.  Emacs runs in a process.  Emacs Lisp
  291. programs can invoke other programs in processes of their own.  These are
  292. called "subprocesses" or "child processes" of the Emacs process, which
  293. is their "parent process".
  294.  
  295.    A subprocess of Emacs may be "synchronous" or "asynchronous",
  296. depending on how it is created.  When you create a synchronous
  297. subprocess, the Lisp program waits for the subprocess to terminate
  298. before continuing execution.  When you create an asynchronous
  299. subprocess, it can run in parallel with the Lisp program.  This kind of
  300. subprocess is represented within Emacs by a Lisp object which is also
  301. called a "process".  Lisp programs can use this object to communicate
  302. with the subprocess or to control it.  For example, you can send
  303. signals, obtain status information, receive output from the process, or
  304. send input to it.
  305.  
  306.  - Function: processp OBJECT
  307.      This function returns `t' if OBJECT is a process, `nil' otherwise.
  308.  
  309. * Menu:
  310.  
  311. * Subprocess Creation::      Functions that start subprocesses.
  312. * Synchronous Processes::    Details of using synchronous subprocesses.
  313. * Asynchronous Processes::   Starting up an asynchronous subprocess.
  314. * Deleting Processes::       Eliminating an asynchronous subprocess.
  315. * Process Information::      Accessing run-status and other attributes.
  316. * Input to Processes::       Sending input to an asynchronous subprocess.
  317. * Signals to Processes::     Stopping, continuing or interrupting
  318.                                an asynchronous subprocess.
  319. * Output from Processes::    Collecting output from an asynchronous subprocess.
  320. * Sentinels::                Sentinels run when process run-status changes.
  321. * Transaction Queues::         Transaction-based communication with subprocesses.
  322. * TCP::                      Opening network connections.
  323.  
  324. 
  325. File: elisp,  Node: Subprocess Creation,  Next: Synchronous Processes,  Up: Processes
  326.  
  327. Functions that Create Subprocesses
  328. ==================================
  329.  
  330.    There are three functions that create a new subprocess in which to
  331. run a program.  One of them, `start-process', creates an asynchronous
  332. process and returns a process object (*note Asynchronous Processes::.).
  333. The other two, `call-process' and `call-process-region', create a
  334. synchronous process and do not return a process object (*note
  335. Synchronous Processes::.).
  336.  
  337.    Synchronous and asynchronous processes are explained in following
  338. sections.  Since the three functions are all called in a similar
  339. fashion, their common arguments are described here.
  340.  
  341.    In all cases, the function's PROGRAM argument specifies the program
  342. to be run.  An error is signaled if the file is not found or cannot be
  343. executed.  The actual file containing the program is found by following
  344. normal system rules: if the file name is absolute, then the program
  345. must be found in the specified file; if the name is relative, then the
  346. directories in `exec-path' are searched sequentially for a suitable
  347. file.  The variable `exec-path' is initialized when Emacs is started,
  348. based on the value of the environment variable `PATH'.  The standard
  349. file name constructs, `~', `.', and `..', are interpreted as usual in
  350. `exec-path', but environment variable substitutions (`$HOME', etc.) are
  351. not recognized; use `substitute-in-file-name' to perform them (*note
  352. File Name Expansion::.).
  353.  
  354.    Each of the subprocess-creating functions has a BUFFER-OR-NAME
  355. argument which specifies where the standard output from the program will
  356. go.  If BUFFER-OR-NAME is `nil', that says to discard the output unless
  357. a filter function handles it.  (*Note Filter Functions::, and *Note
  358. Streams::.)  Normally, you should avoid having multiple processes send
  359. output to the same buffer because their output would be intermixed
  360. randomly.
  361.  
  362.    All three of the subprocess-creating functions have a `&rest'
  363. argument, ARGS.  The ARGS must all be strings, and they are supplied to
  364. PROGRAM as separate command line arguments.  Wildcard characters and
  365. other shell constructs are not allowed in these strings, since they are
  366. passed directly to the specified program.
  367.  
  368.    *Please note:* the argument PROGRAM contains only the name of the
  369. program; it may not contain any command-line arguments.  Such arguments
  370. must be provided via ARGS.
  371.  
  372.    The subprocess gets its current directory from the value of
  373. `default-directory' (*note File Name Expansion::.).
  374.  
  375.    The subprocess inherits its environment from Emacs; but you can
  376. specify overrides for it with `process-environment'.  *Note System
  377. Environment::.
  378.  
  379.  - Variable: exec-directory
  380.      The value of this variable is the name of a directory (a string)
  381.      that contains programs that come with GNU Emacs, that are intended
  382.      for Emacs to invoke.  The program `wakeup' is an example of such a
  383.      program; the `display-time' command uses it to get a reminder once
  384.      per minute.
  385.  
  386.      The default value is the name of a directory whose name ends in
  387.      `arch-lib'.  We call the directory `emacs/arch-lib', since its
  388.      name usually ends that way.  We sometimes refer to "the directory
  389.      `emacs/arch-lib'," when strictly speaking we ought to say, "the
  390.      directory named by the variable `exec-directory'."  Most of the
  391.      time, there is no difference.
  392.  
  393.      (In earlier Emacs versions, prior to version 19, these files lived
  394.      in the directory `emacs/etc' instead of in `emacs/arch-lib'.)
  395.  
  396.  - User Option: exec-path
  397.      The value of this variable is a list of directories to search for
  398.      programs to run in subprocesses.  Each element is either the name
  399.      of a directory (i.e., a string), or `nil', which stands for the
  400.      default directory (which is the value of `default-directory').
  401.  
  402.      The value of `exec-path' is used by `call-process' and
  403.      `start-process' when the PROGRAM argument is not an absolute file
  404.      name.
  405.  
  406. 
  407. File: elisp,  Node: Synchronous Processes,  Next: Asynchronous Processes,  Prev: Subprocess Creation,  Up: Processes
  408.  
  409. Creating a Synchronous Process
  410. ==============================
  411.  
  412.    After a "synchronous process" is created, Emacs waits for the
  413. process to terminate before continuing.  Starting Dired is an example of
  414. this: it runs `ls' in a synchronous process, then modifies the output
  415. slightly.  Because the process is synchronous, the entire directory
  416. listing arrives in the buffer before Emacs tries to do anything with it.
  417.  
  418.    While Emacs waits for the synchronous subprocess to terminate, the
  419. user can quit by typing `C-g', and the process is killed by sending it
  420. a `SIGKILL' signal.  *Note Quitting::.
  421.  
  422.    The synchronous subprocess functions return `nil' in version 18.  In
  423. version 19, they will return an indication of how the process
  424. terminated.
  425.  
  426.  - Function: call-process PROGRAM &optional INFILE BUFFER-OR-NAME
  427.           DISPLAY &rest ARGS
  428.      This function calls PROGRAM in a separate process and waits for it
  429.      to finish.
  430.  
  431.      The standard input for the process comes from file INFILE if
  432.      INFILE is not `nil' and from `/dev/null' otherwise.  The process
  433.      output gets inserted in buffer BUFFER-OR-NAME before point, if
  434.      that argument names a buffer.  If BUFFER-OR-NAME is `t', output is
  435.      sent to the current buffer; if BUFFER-OR-NAME is `nil', output is
  436.      discarded.
  437.  
  438.      If BUFFER-OR-NAME is the integer 0, `call-process' returns `nil'
  439.      immediately and discards any output.  In this case, the process is
  440.      not truly synchronous, since it can run in parallel with Emacs;
  441.      but you can think of it as synchronous in that Emacs is
  442.      essentially finished with the subprocess as soon as this function
  443.      returns.
  444.  
  445.      If DISPLAY is non-`nil', then `call-process' redisplays the buffer
  446.      as output is inserted.  Otherwise the function does no redisplay,
  447.      and the results become visible on the screen only when Emacs
  448.      redisplays that buffer in the normal course of events.
  449.  
  450.      The remaining arguments, ARGS, are strings that are supplied as
  451.      the command line arguments for the program.
  452.  
  453.      The value returned by `call-process' (unless you told it not to
  454.      wait) indicates the reason for process termination.  A number
  455.      gives the exit status of the subprocess; 0 means success, and any
  456.      other value means failure.  If the process terminated with a
  457.      signal, `call-process' returns a string describing the signal.
  458.  
  459.      The examples below are both run with the buffer `foo' current.
  460.  
  461.           (call-process "pwd" nil t)
  462.                => nil
  463.           
  464.           ---------- Buffer: foo ----------
  465.           /usr/user/lewis/manual
  466.           ---------- Buffer: foo ----------
  467.  
  468.           (call-process "grep" nil "bar" nil "lewis" "/etc/passwd")
  469.                => nil
  470.           
  471.           ---------- Buffer: bar ----------
  472.           lewis:5LTsHm66CSWKg:398:21:Bil Lewis:/user/lewis:/bin/csh
  473.           
  474.           ---------- Buffer: bar ----------
  475.  
  476.      The `dired-readin' function contains a good example of the use of
  477.      `call-process':
  478.  
  479.           (call-process
  480.            "ls" nil buffer nil dired-listing-switches dirname)
  481.  
  482.  - Function: call-process-region START END PROGRAM &optional DELETE
  483.           BUFFER-OR-NAME DISPLAY &rest ARGS
  484.      This function sends the text between START to END as standard
  485.      input to a process running PROGRAM.  It deletes the text sent if
  486.      DELETE is non-`nil', which may be useful when the output is going
  487.      to be inserted back in the current buffer.
  488.  
  489.      If BUFFER-OR-NAME names a buffer, the output is inserted in that
  490.      buffer at point.  If BUFFER-OR-NAME is `t', the output is sent to
  491.      the current buffer.  If BUFFER-OR-NAME is `nil', the output is
  492.      discarded.  If BUFFER-OR-NAME is the integer 0, the output is
  493.      discarded and `call-process' returns `nil' immediately, just as
  494.      `call-process' would.
  495.  
  496.      If DISPLAY is non-`nil', then `call-process-region' redisplays the
  497.      buffer as output is inserted.  Otherwise the function does no
  498.      redisplay, and the results become visible on the screen only when
  499.      Emacs redisplays that buffer in the normal course of events.
  500.  
  501.      The remaining arguments, ARGS, are strings that are supplied as
  502.      the command line arguments for the program.
  503.  
  504.      The return value of `call-process-region' is just like that of
  505.      `call-process': `nil' if you told it to return without waiting;
  506.      otherwise, a number or string which indicates how the subprocess
  507.      terminated.
  508.  
  509.      In the following example, we use `call-process-region' to run the
  510.      `cat' utility, with standard input being the first five characters
  511.      in buffer `foo' (the word `input').  `cat' copies its standard
  512.      input into its standard output.  Since the argument BUFFER-OR-NAME
  513.      is `t', this output is inserted in the current buffer.
  514.  
  515.           ---------- Buffer: foo ----------
  516.           input-!-
  517.           ---------- Buffer: foo ----------
  518.  
  519.           (call-process-region 1 6 "cat" nil t)
  520.                => nil
  521.           
  522.           ---------- Buffer: foo ----------
  523.           inputinput-!-
  524.           ---------- Buffer: foo ----------
  525.  
  526.      The `shell-command-on-region' command uses `call-process-region'
  527.      like this:
  528.  
  529.           (call-process-region
  530.            start end
  531.            shell-file-name      ; Name of program.
  532.            nil                  ; Do not delete region.
  533.            buffer               ; Send output to `buffer'.
  534.            nil                  ; No redisplay during output.
  535.            "-c" command)        ; Arguments for the shell.
  536.  
  537. 
  538. File: elisp,  Node: Asynchronous Processes,  Next: Deleting Processes,  Prev: Synchronous Processes,  Up: Processes
  539.  
  540. Creating an Asynchronous Process
  541. ================================
  542.  
  543.    After an "asynchronous process" is created, Emacs and the Lisp
  544. program can continue running immediately.  The process may thereafter
  545. run in parallel with Emacs, and the two may communicate with each other
  546. using the functions described in following sections.  Here we describe
  547. how to create an asynchronous process, with `start-process'.
  548.  
  549.  - Function: start-process NAME BUFFER-OR-NAME PROGRAM &rest ARGS
  550.      This function creates a new asynchronous subprocess and starts the
  551.      program PROGRAM running in it.  It returns a process object that
  552.      stands for the new subprocess for Emacs Lisp programs.  The
  553.      argument NAME specifies the name for the process object; if a
  554.      process with this name already exists, then NAME is modified (by
  555.      adding `<1>', etc.) to be unique.  The buffer BUFFER-OR-NAME is the
  556.      buffer to associate with the process.
  557.  
  558.      The remaining arguments, ARGS, are strings that are supplied as
  559.      the command line arguments for the program.
  560.  
  561.      In the example below, the first process is started and runs
  562.      (rather, sleeps) for 100 seconds.  Meanwhile, the second process
  563.      is started, given the name `my-process<1>' for the sake of
  564.      uniqueness.  It inserts the directory listing at the end of the
  565.      buffer `foo', before the first process finishes.  Then it
  566.      finishes, and a message to that effect is inserted in the buffer.
  567.      Much later, the first process finishes, and another message is
  568.      inserted in the buffer for it.
  569.  
  570.           (start-process "my-process" "foo" "sleep" "100")
  571.                => #<process my-process>
  572.  
  573.           (start-process "my-process" "foo" "ls" "-l" "/user/lewis/bin")
  574.                => #<process my-process<1>>
  575.           
  576.           ---------- Buffer: foo ----------
  577.           total 2
  578.           lrwxrwxrwx  1 lewis     14 Jul 22 10:12 gnuemacs --> /emacs
  579.           -rwxrwxrwx  1 lewis     19 Jul 30 21:02 lemon
  580.           
  581.           Process my-process<1> finished
  582.           
  583.           Process my-process finished
  584.           ---------- Buffer: foo ----------
  585.  
  586.  - Function: start-process-shell-command NAME BUFFER-OR-NAME COMMAND
  587.           &rest COMMAND-ARGS
  588.      This function is like `start-process' except that it uses a shell
  589.      to execute the specified command.  The argument COMMAND is a shell
  590.      command name, and COMMAND-ARGS are the arguments for the shell
  591.      command.
  592.  
  593.  - Variable: process-connection-type
  594.      This variable controls the type of device used to communicate with
  595.      asynchronous subprocesses.  If it is `nil', then pipes are used.
  596.      If it is `t', then PTYs are used (or pipes if PTYs are not
  597.      supported).
  598.  
  599.      PTYs are usually preferable for processes visible to the user, as
  600.      in Shell mode, because they allow job control (`C-c', `C-z', etc.)
  601.      to work between the process and its children whereas pipes do not.
  602.      For subprocesses used for internal purposes by programs, it is
  603.      often better to use a pipe, because they are more efficient.  In
  604.      addition, the total number of PTYs is limited on many systems and
  605.      it is good not to waste them.
  606.  
  607.      The value `process-connection-type' is used when `start-process'
  608.      is called, so in order to change it for just one call of
  609.      `start-process', temporarily rebind it with `let'.
  610.  
  611.           (let ((process-connection-type nil))  ; Use a pipe.
  612.             (start-process ...))
  613.  
  614. 
  615. File: elisp,  Node: Deleting Processes,  Next: Process Information,  Prev: Asynchronous Processes,  Up: Processes
  616.  
  617. Deleting Processes
  618. ==================
  619.  
  620.    "Deleting a process" disconnects Emacs immediately from the
  621. subprocess, and removes it from the list of active processes.  It sends
  622. a signal to the subprocess to make the subprocess terminate, but this is
  623. not guaranteed to happen immediately.  (The process object itself
  624. continues to exist as long as other Lisp objects point to it.)
  625.  
  626.    You can delete a process explicitly at any time.  Processes are
  627. deleted automatically after they terminate, but not necessarily right
  628. away.  If you delete a terminated process explicitly before it is
  629. deleted automatically, no harm results.
  630.  
  631.  - Variable: delete-exited-processes
  632.      This variable controls automatic deletion of processes that have
  633.      terminated (due to calling `exit' or to a signal).  If it is
  634.      `nil', then they continue to exist until the user runs
  635.      `list-processes'.  Otherwise, they are deleted immediately after
  636.      they exit.
  637.  
  638.  - Function: delete-process NAME
  639.      This function deletes the process associated with NAME.  The
  640.      argument NAME may be a process, the name of a process, a buffer,
  641.      or the name of a buffer.  The subprocess is killed with a `SIGHUP'
  642.      signal.
  643.  
  644.           (delete-process "*shell*")
  645.                => nil
  646.  
  647.  - Function: process-kill-without-query PROCESS
  648.      This function declares that Emacs need not query the user if
  649.      PROCESS is still running when Emacs is exited.  The process will
  650.      be deleted silently.  The value is `t'.
  651.  
  652.           (process-kill-without-query (get-process "shell"))
  653.                => t
  654.  
  655. 
  656. File: elisp,  Node: Process Information,  Next: Input to Processes,  Prev: Deleting Processes,  Up: Processes
  657.  
  658. Process Information
  659. ===================
  660.  
  661.    Several functions return information about processes.
  662. `list-processes' is provided for interactive use.
  663.  
  664.  - Command: list-processes
  665.      This command displays a listing of all living processes.  (Any
  666.      processes listed as `Exited' or `Signaled' are actually eliminated
  667.      after the listing is made.)  This function returns `nil'.
  668.  
  669.  - Function: process-list
  670.      This function returns a list of all processes that have not been
  671.      deleted.
  672.  
  673.           (process-list)
  674.                => (#<process display-time> #<process shell>)
  675.  
  676.  - Function: get-process NAME
  677.      This function returns the process named NAME, or `nil' if there is
  678.      none.  An error is signaled if NAME is not a string.
  679.  
  680.           (get-process "shell")
  681.                => #<process shell>
  682.  
  683.  - Function: process-command PROCESS
  684.      This function returns the command that was executed to start
  685.      PROCESS.  This is a list of strings, the first string being the
  686.      program executed and the rest of the strings being the arguments
  687.      that were given to the program.
  688.  
  689.           (process-command (get-process "shell"))
  690.                => ("/bin/csh" "-i")
  691.  
  692.  - Function: process-exit-status PROCESS
  693.      This function returns the exit status of PROCESS or the signal
  694.      number that killed it.  (Use the result of `process-status' to
  695.      determine which of those it is.)  If PROCESS has not yet
  696.      terminated, the value is 0.
  697.  
  698.  - Function: process-id PROCESS
  699.      This function returns the PID of PROCESS.  This is an integer
  700.      which distinguishes the process PROCESS from all other processes
  701.      running on the same computer at the current time.  The PID of a
  702.      process is chosen by the operating system kernel when the process
  703.      is started and remains constant as long as the process exists.
  704.  
  705.  - Function: process-name PROCESS
  706.      This function returns the name of PROCESS.
  707.  
  708.  - Function: process-status PROCESS-NAME
  709.      This function returns the status of PROCESS-NAME as a symbol.  The
  710.      argument PROCESS-NAME must be a process, a buffer, a process name
  711.      (string) or a buffer name (string).
  712.  
  713.      The possible values for an actual subprocess are:
  714.  
  715.     `run'
  716.           for a process that is running.
  717.  
  718.     `stop'
  719.           for a process that is stopped but continuable.
  720.  
  721.     `exit'
  722.           for a process that has exited.
  723.  
  724.     `signal'
  725.           for a process that has received a fatal signal.
  726.  
  727.     `open'
  728.           for a network connection that is open.
  729.  
  730.     `closed'
  731.           for a network connection that is closed.  Once a connection
  732.           is closed, you cannot reopen it, though you might be able to
  733.           open a new connection to the same place.
  734.  
  735.     `nil'
  736.           if PROCESS-NAME is not the name of an existing process.
  737.  
  738.           (process-status "shell")
  739.                => run
  740.  
  741.           (process-status (get-buffer "*shell*"))
  742.                => run
  743.  
  744.           x
  745.                => #<process xx<1>>
  746.           (process-status x)
  747.                => exit
  748.  
  749.      For a network connection, `process-status' returns one of the
  750.      symbols `open' or `closed'.  The latter means that the other side
  751.      closed the connection, or Emacs did `delete-process'.
  752.  
  753.      In earlier Emacs versions (prior to version 19), the status of a
  754.      network connection was `run' if open, and `exit' if closed.
  755.  
  756. 
  757. File: elisp,  Node: Input to Processes,  Next: Signals to Processes,  Prev: Process Information,  Up: Processes
  758.  
  759. Sending Input to Processes
  760. ==========================
  761.  
  762.    Asynchronous subprocesses receive input when it is sent to them by
  763. Emacs, which is done with the functions in this section.  You must
  764. specify the process to send input to, and the input data to send.  The
  765. data appears on the "standard input" of the subprocess.
  766.  
  767.    Some operating systems have limited space for buffered input in a
  768. PTY.  On these systems, the subprocess will cease to read input
  769. correctly if you send an input line longer than the system can handle.
  770. You cannot avoid the problem by breaking the input into pieces and
  771. sending them separately, for the operating system will still have to put
  772. all the pieces together in the input buffer before it lets the
  773. subprocess read the line.  The only solution is to put the input in a
  774. temporary file, and send the process a brief command to read that file.
  775.  
  776.  - Function: process-send-string PROCESS-NAME STRING
  777.      This function sends PROCESS-NAME the contents of STRING as
  778.      standard input.  The argument PROCESS-NAME must be a process or
  779.      the name of a process.
  780.  
  781.      The function returns `nil'.
  782.  
  783.           (process-send-string "shell<1>" "ls\n")
  784.                => nil
  785.  
  786.           ---------- Buffer: *shell* ----------
  787.           ...
  788.           introduction.texi               syntax-tables.texi~
  789.           introduction.texi~              text.texi
  790.           introduction.txt                text.texi~
  791.           ...
  792.           ---------- Buffer: *shell* ----------
  793.  
  794.  - Command: process-send-region PROCESS-NAME START END
  795.      This function sends the text in the region defined by START and
  796.      END as standard input to PROCESS-NAME, which is a process or a
  797.      process name.
  798.  
  799.      An error is signaled unless both START and END are integers or
  800.      markers that indicate positions in the current buffer.  (It is
  801.      unimportant which number is larger.)
  802.  
  803.  - Function: process-send-eof &optional PROCESS-NAME
  804.      This function makes PROCESS-NAME see an end-of-file in its input.
  805.      The EOF comes after any text already sent to it.
  806.  
  807.      If PROCESS-NAME is not supplied, or if it is `nil', then this
  808.      function sends the EOF to the current buffer's process.  An error
  809.      is signaled if the current buffer has no process.
  810.  
  811.      The function returns PROCESS-NAME.
  812.  
  813.           (process-send-eof "shell")
  814.                => "shell"
  815.  
  816. 
  817. File: elisp,  Node: Signals to Processes,  Next: Output from Processes,  Prev: Input to Processes,  Up: Processes
  818.  
  819. Sending Signals to Processes
  820. ============================
  821.  
  822.    "Sending a signal" to a subprocess is a way of interrupting its
  823. activities.  There are several different signals, each with its own
  824. meaning.  For example, the signal `SIGINT' means that the user has
  825. typed `C-c', or that some analogous thing has happened.
  826.  
  827.    Each signal has a standard effect on the subprocess.  Most signals
  828. kill the subprocess, but some stop or resume execution instead.  Most
  829. signals can optionally be handled by programs; if the program handles
  830. the signal, then we can say nothing in general about its effects.
  831.  
  832.    The set of signals and their names is defined by the operating
  833. system; Emacs has facilities for sending only a few of the signals that
  834. are defined.  Emacs can send signals only to its own subprocesses.
  835.  
  836.    You can send signals explicitly by calling the functions in this
  837. section.  Emacs also sends signals automatically at certain times:
  838. killing a buffer sends a `SIGHUP' signal to all its associated
  839. processes; killing Emacs sends a `SIGHUP' signal to all remaining
  840. processes.  (`SIGHUP' is a signal that usually indicates that the user
  841. hung up the phone.)
  842.  
  843.    Each of the signal-sending functions takes two optional arguments:
  844. PROCESS-NAME and CURRENT-GROUP.
  845.  
  846.    The argument PROCESS-NAME must be either a process, the name of one,
  847. or `nil'.  If it is `nil', the process defaults to the process
  848. associated with the current buffer.  An error is signaled if
  849. PROCESS-NAME does not identify a process.
  850.  
  851.    The argument CURRENT-GROUP is a flag that makes a difference when
  852. you are running a job-control shell as an Emacs subprocess.  If it is
  853. non-`nil', then the signal is sent to the current process-group of the
  854. terminal which Emacs uses to communicate with the subprocess.  If the
  855. process is a job-control shell, this means the shell's current subjob.
  856. If it is `nil', the signal is sent to the process group of the
  857. immediate subprocess of Emacs.  If the subprocess is a job-control
  858. shell, this is the shell itself.
  859.  
  860.    The flag CURRENT-GROUP has no effect when a pipe is used to
  861. communicate with the subprocess, because the operating system does not
  862. support the distinction in the case of pipes.  For the same reason,
  863. job-control shells won't work when a pipe is used.  See
  864. `process-connection-type' in *Note Asynchronous Processes::.
  865.  
  866.  - Function: interrupt-process &optional PROCESS-NAME CURRENT-GROUP
  867.      This function interrupts the process PROCESS-NAME by sending the
  868.      signal `SIGINT'.  Outside of Emacs, typing the "interrupt
  869.      character" (normally `C-c' on some systems, and `DEL' on others)
  870.      sends this signal.  When the argument CURRENT-GROUP is non-`nil',
  871.      you can think of this function as "typing `C-c'" on the terminal
  872.      by which Emacs talks to the subprocess.
  873.  
  874.  - Function: kill-process &optional PROCESS-NAME CURRENT-GROUP
  875.      This function kills the process PROCESS-NAME by sending the signal
  876.      `SIGKILL'.  This signal kills the subprocess immediately, and
  877.      cannot be handled by the subprocess.
  878.  
  879.  - Function: quit-process &optional PROCESS-NAME CURRENT-GROUP
  880.      This function sends the signal `SIGQUIT' to the process
  881.      PROCESS-NAME.  This signal is the one sent by the "quit character"
  882.      (usually `C-b' or `C-\') when you are not inside Emacs.
  883.  
  884.  - Function: stop-process &optional PROCESS-NAME CURRENT-GROUP
  885.      This function stops the process PROCESS-NAME by sending the signal
  886.      `SIGTSTP'.  Use `continue-process' to resume its execution.
  887.  
  888.      On systems with job control, the "stop character" (usually `C-z')
  889.      sends this signal (outside of Emacs).  When CURRENT-GROUP is
  890.      non-`nil', you can think of this function as "typing `C-z'" on the
  891.      terminal Emacs uses to communicate with the subprocess.
  892.  
  893.  - Function: continue-process &optional PROCESS-NAME CURRENT-GROUP
  894.      This function resumes execution of the process PROCESS by sending
  895.      it the signal `SIGCONT'.  This presumes that PROCESS-NAME was
  896.      stopped previously.
  897.  
  898.  - Function: signal-process PID SIGNAL
  899.      This function sends a signal to process PID, which need not be a
  900.      child of Emacs.  The argument SIGNAL specifies which signal to
  901.      send; it should be an integer.
  902.  
  903. 
  904. File: elisp,  Node: Output from Processes,  Next: Sentinels,  Prev: Signals to Processes,  Up: Processes
  905.  
  906. Receiving Output from Processes
  907. ===============================
  908.  
  909.    There are two ways to receive the output that a subprocess writes to
  910. its standard output stream.  The output can be inserted in a buffer,
  911. which is called the associated buffer of the process, or a function
  912. called the "filter function" can be called to act on the output.
  913.  
  914. * Menu:
  915.  
  916. * Process Buffers::       If no filter, output is put in a buffer.
  917. * Filter Functions::      Filter functions accept output from the process.
  918. * Accepting Output::      Explicitly permitting subprocess output.
  919.                             Waiting for subprocess output.
  920.  
  921. 
  922. File: elisp,  Node: Process Buffers,  Next: Filter Functions,  Up: Output from Processes
  923.  
  924. Process Buffers
  925. ---------------
  926.  
  927.    A process can (and usually does) have an "associated buffer", which
  928. is an ordinary Emacs buffer that is used for two purposes: storing the
  929. output from the process, and deciding when to kill the process.  You
  930. can also use the buffer to identify a process to operate on, since in
  931. normal practice only one process is associated with any given buffer.
  932. Many applications of processes also use the buffer for editing input to
  933. be sent to the process, but this is not built into Emacs Lisp.
  934.  
  935.    Unless the process has a filter function (*note Filter Functions::.),
  936. its output is inserted in the associated buffer.  The position to insert
  937. the output is determined by the `process-mark' (*note Process
  938. Information::.), which is then updated to point to the end of the text
  939. just inserted.  Usually, but not always, the `process-mark' is at the
  940. end of the buffer.  If the process has no buffer and no filter
  941. function, its output is discarded.
  942.  
  943.  - Function: process-buffer PROCESS
  944.      This function returns the associated buffer of the process PROCESS.
  945.  
  946.           (process-buffer (get-process "shell"))
  947.                => #<buffer *shell*>
  948.  
  949.  - Function: process-mark PROCESS
  950.      This function returns the marker which controls where additional
  951.      output from the process will be inserted in the process buffer.
  952.      When output is inserted, the marker is updated to point at the end
  953.      of the output.  This causes successive batches of output to be
  954.      inserted consecutively.
  955.  
  956.      If PROCESS does not insert its output into a buffer, then
  957.      `process-mark' returns a marker that points nowhere.
  958.  
  959.      Filter functions normally should use this marker in the same
  960.      fashion as is done by direct insertion of output in the buffer.  A
  961.      good example of a filter function that uses `process-mark' is
  962.      found at the end of the following section.
  963.  
  964.      When the user is expected to enter input in the process buffer for
  965.      transmission to the process, the process marker is useful for
  966.      distinguishing the new input from previous output.
  967.  
  968.  - Function: set-process-buffer PROCESS BUFFER
  969.      This function sets the buffer associated with PROCESS to BUFFER.
  970.      If BUFFER is `nil', the process will not be associated with any
  971.      buffer.
  972.  
  973.  - Function: get-buffer-process BUFFER-OR-NAME
  974.      This function returns the process associated with BUFFER-OR-NAME.
  975.      If there are several processes associated with it, then one is
  976.      chosen.  (Presently, the one chosen is the one most recently
  977.      created.)  It is usually a bad idea to have more than one process
  978.      associated with the same buffer.
  979.  
  980.           (get-buffer-process "*shell*")
  981.                => #<process shell>
  982.  
  983.      If the process's buffer is killed, the actual child process is
  984.      killed with a `SIGHUP' signal (*note Signals to Processes::.).
  985.  
  986. 
  987. File: elisp,  Node: Filter Functions,  Next: Accepting Output,  Prev: Process Buffers,  Up: Output from Processes
  988.  
  989. Process Filter Functions
  990. ------------------------
  991.  
  992.    A process "filter function" is a function that receives the standard
  993. output from the associated process.  If a process has a filter, then
  994. *all* output from that process, that would otherwise have been in a
  995. buffer, is passed to the filter.  The process buffer is used for output
  996. from the process only when there is no filter.
  997.  
  998.    A filter function must accept two arguments: the associated process
  999. and a string, which is the output.  The function is then free to do
  1000. whatever it chooses with the output.
  1001.  
  1002.    A filter function runs only while Emacs is waiting (e.g., for
  1003. terminal input, or for time to elapse, or for process output).  This
  1004. avoids the timing errors that could result from running filters at
  1005. random places in the middle of other Lisp programs.  You may explicitly
  1006. cause Emacs to wait, so that filter functions will run, by calling
  1007. `sit-for', `sleep-for' or `accept-process-output' (*note Accepting
  1008. Output::.).  Emacs is also waiting when the command loop is reading
  1009. input.
  1010.  
  1011.    Quitting is normally inhibited within a filter function--otherwise,
  1012. the effect of typing `C-g' at command level or to quit a user command
  1013. would be unpredictable.  If you want to permit quitting inside a filter
  1014. function, bind `inhibit-quit' to `nil'.  *Note Quitting::.
  1015.  
  1016.    Many filter functions sometimes or always insert the text in the
  1017. process's buffer, mimicking the actions of Emacs when there is no
  1018. filter.  Such filter functions need to use `set-buffer' in order to be
  1019. sure to insert in that buffer.  To avoid setting the current buffer
  1020. semipermanently, these filter functions must use `unwind-protect' to
  1021. make sure to restore the previous current buffer.  They should also
  1022. update the process marker, and in some cases update the value of point.
  1023. Here is how to do these things:
  1024.  
  1025.      (defun ordinary-insertion-filter (proc string)
  1026.        (let ((old-buffer (current-buffer)))
  1027.          (unwind-protect
  1028.              (let (moving)
  1029.                (set-buffer (process-buffer proc))
  1030.                (setq moving (= (point) (process-mark proc)))
  1031.  
  1032.      (save-excursion
  1033.                  ;; Insert the text, moving the process-marker.
  1034.                  (goto-char (process-mark proc))
  1035.                  (insert string)
  1036.                  (set-marker (process-mark proc) (point)))
  1037.                (if moving (goto-char (process-mark proc))))
  1038.            (set-buffer old-buffer))))
  1039.  
  1040. The reason to use an explicit `unwind-protect' rather than letting
  1041. `save-excursion' restore the current buffer is so as to preserve the
  1042. change in point made by `goto-char'.
  1043.  
  1044.    To make the filter force the process buffer to be visible whenever
  1045. new text arrives, insert the following line just before the
  1046. `unwind-protect':
  1047.  
  1048.      (display-buffer (process-buffer proc))
  1049.  
  1050.    To force point to move to the end of the new output no matter where
  1051. it was previously, eliminate the variable `moving' and call `goto-char'
  1052. unconditionally.
  1053.  
  1054.    All filter functions that do regexp searching or matching should save
  1055. and restore the match data.  Otherwise, a filter function that runs
  1056. during a call to `sit-for' might clobber the match data of the program
  1057. that called `sit-for'.  *Note Match Data::.
  1058.  
  1059.    The output to the function may come in chunks of any size.  A program
  1060. that produces the same output twice in a row may send it as one batch
  1061. of 200 characters one time, and five batches of 40 characters the next.
  1062.  
  1063.  - Function: set-process-filter PROCESS FILTER
  1064.      This function gives PROCESS the filter function FILTER.  If FILTER
  1065.      is `nil', then the process will have no filter.
  1066.  
  1067.  - Function: process-filter PROCESS
  1068.      This function returns the filter function of PROCESS, or `nil' if
  1069.      it has none.
  1070.  
  1071.    Here is an example of use of a filter function:
  1072.  
  1073.      (defun keep-output (process output)
  1074.         (setq kept (cons output kept)))
  1075.           => keep-output
  1076.  
  1077.      (setq kept nil)
  1078.           => nil
  1079.  
  1080.      (set-process-filter (get-process "shell") 'keep-output)
  1081.           => keep-output
  1082.  
  1083.      (process-send-string "shell" "ls ~/other\n")
  1084.           => nil
  1085.      kept
  1086.           => ("lewis@slug[8] % "
  1087.  
  1088.      "FINAL-W87-SHORT.MSS    backup.otl              kolstad.mss~
  1089.      address.txt             backup.psf              kolstad.psf
  1090.      backup.bib~             david.mss               resume-Dec-86.mss~
  1091.      backup.err              david.psf               resume-Dec.psf
  1092.      backup.mss              dland                   syllabus.mss
  1093.      "
  1094.      "#backups.mss#          backup.mss~             kolstad.mss
  1095.      ")
  1096.  
  1097.    Here is another, more realistic example, which demonstrates how to
  1098. use the process mark to do insertion in the same fashion as is done when
  1099. there is no filter function:
  1100.  
  1101.      ;; Insert input in the buffer specified by `my-shell-buffer'
  1102.      ;;   and make sure that buffer is shown in some window.
  1103.      (defun my-process-filter (proc str)
  1104.          (let ((cur (selected-window))
  1105.                (pop-up-windows t))
  1106.            (pop-to-buffer my-shell-buffer)
  1107.  
  1108.      (goto-char (point-max))
  1109.            (insert str)
  1110.            (set-marker (process-mark proc) (point-max))
  1111.            (select-window cur)))
  1112.  
  1113. 
  1114. File: elisp,  Node: Accepting Output,  Prev: Filter Functions,  Up: Output from Processes
  1115.  
  1116. Accepting Output from Processes
  1117. -------------------------------
  1118.  
  1119.    Output from asynchronous subprocesses normally arrives only while
  1120. Emacs is waiting for some sort of external event, such as elapsed time
  1121. or terminal input.  Occasionally it is useful in a Lisp program to
  1122. explicitly permit output to arrive at a specific point, or even to wait
  1123. until output arrives from a process.
  1124.  
  1125.  - Function: accept-process-output &optional PROCESS SECONDS MILLISEC
  1126.      This function allows Emacs to read pending output from processes.
  1127.      The output is inserted in the associated buffers or given to their
  1128.      filter functions.  If PROCESS is non-`nil' then this function does
  1129.      not return until some output has been received from PROCESS.
  1130.  
  1131.      The arguments SECONDS and MILLISEC let you specify timeout
  1132.      periods.  The former specifies a period measured in seconds and the
  1133.      latter specifies one measured in milliseconds.  The two time
  1134.      periods thus specified are added together, and
  1135.      `accept-process-output' returns after that much time whether or
  1136.      not there has been any subprocess output.
  1137.  
  1138.      Not all operating systems support waiting periods other than
  1139.      multiples of a second; on those that do not, you get an error if
  1140.      you specify nonzero MILLISEC.
  1141.  
  1142.      The function `accept-process-output' returns non-`nil' if it did
  1143.      get some output, or `nil' if the timeout expired before output
  1144.      arrived.
  1145.  
  1146.